
import { HelloCmd, LoginCmd } from "./CmdData";
import CmdMgr from "./CmdMgr";
import WebSocketManager from "./WebSocketMrg";

export default class SendMgr {

  public static LoginVerify() {
    let msg: gameMsg.ILoginVerify = {
      age: 273676,
      jwt: "demotest",
      loginBizCode: 1
    }



    // let message = gameMsg.LoginVerify.create(msg);
    let buffer = gameMsg.LoginVerify.encode(msg).finish();
    this.send(CmdMgr.getMergeCmd(LoginCmd.Cmd, LoginCmd.Sub_Verify), buffer);
    // SocketClient.ins.send(LoginVerifyCmd, LoginVerifySubCmd, msg)
  }

  public static send(mergeCmd: number, data: Uint8Array, cmdCode: number = 1, protocolSwitch: number = 0) {
    let msg: gameMsg.IMyExternalMessage = {
      cmdCode: cmdCode,
      protocolSwitch: protocolSwitch,
      cmdMerge: mergeCmd,
      responseStatus: 0,
      validMsg: "",
      dataContent: data
    }

    // let message = gameMsg.MyExternalMessage.create(msg);
    let buffer = gameMsg.MyExternalMessage.encode(msg).finish();
    WebSocketManager.instance().send(buffer);
  }
}
